package com.example.client.api.unit;

import com.example.server.pojo.User;
import com.example.server.service.UserService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.HashMap;

@Controller
@RequestMapping("/user")
@CrossOrigin
@Slf4j
public class UserController {
    @Resource
    private UserService userService;
    @CrossOrigin
    @GetMapping("/identify")//身份证审核
    @ResponseBody
    public HashMap<String,Object> identify(String user_name, String user_identify){
        HashMap<String,Object> result = new HashMap<>();
        String r= userService.identify(user_name,user_identify);
        log.info("证件审核姓名:"+user_name+",身份证号码："+user_identify+",结果："+r);
        result.put("result",r);
        return result;
    }
    @CrossOrigin
    @GetMapping("/getuserinfo")//用户信息检验，返回该用户基础信息
    @ResponseBody
    public HashMap<String,Object> getuserinfo(String user_id){
        HashMap<String,Object> result = new HashMap<>();
        User user =userService.getuserinfo(user_id);
        log.info("接口getuserinfo:"+user);
        result.put("result",user);
        return result;
    }
    @CrossOrigin
    @GetMapping("/updateuserinfo")//用户信息检验后更新用户信息，
    @ResponseBody
    public HashMap<String,Object> updateuserinfo(String user_tql, String user_id){
        HashMap<String,Object> result = new HashMap<>();
        log.info("接口updateuserinfo,user_tql"+user_tql+",user_id:"+user_id);
        result.put("result", userService.updateuserinfo(user_tql,user_id));
        return result;
    }
    @CrossOrigin
    @GetMapping("/whiteuser")//检验是否为白名单用户
    @ResponseBody
    public HashMap<String,Object> whiteuser(String user_id){
        HashMap<String,Object> result = new HashMap<>();
        log.info("接口whiteuser,user_id"+user_id);
        result.put("result", userService.whiteuser(user_id));
        return result;
    }
}
